#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "GB28181Device.h"


CGB28181Device*		g_pImp = NULL;

void ShowHelpInfo();

int main()
{
	g_pImp = new CGB28181Device;
	assert(g_pImp != NULL);
	if(g_pImp->Init() == false)
	{
		printf("faild to init sdk!\n");
		return -1;
	}
	printf("Init success!\n");
	ShowHelpInfo();

	char c = 0;
	while ((c = getchar()) != 'q')
	{
		if (c == 's') //start
		{
			g_pImp->Start();
		}
		else if (c == 'c') //stop
		{
			g_pImp->Stop();
		}
		else if (c == 'a') //alarm status update
		{
			g_pImp->AlarmStatusUpdate();
		}
		else if (c == 'g') //GPS info report
		{
			g_pImp->ReportGpsImmediate();
		}
		else if (c == 'r') //register status quest
		{
			if (g_pImp->GetRegisterStatus() == STATUS_REGISTER)
			{
				printf("\nGB28181 register status: register!\n");
			}
			else
			{
				printf("\nGB28181 register status: not register!\n");
			}
			
		}
		else if (c == 'h' || c == 'H')
		{
			ShowHelpInfo();
		}
		else
		{

		}
	}
	
	if (g_pImp)
	{
		g_pImp->Quit();
		delete g_pImp;
		g_pImp = NULL;
	}
	printf("quit!\n");
	return 0;
}

void ShowHelpInfo()
{
	printf("\n================Help info================================\n");
	printf("s:  start\n");
	printf("c:  stop\n");
	printf("a:  alarm status update\n");
	printf("r:  register status query\n");
	printf("q:  quit\n");
	printf("==========================================================\n");
}